import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';
import { ProjectMetric } from './project-metric.entity';
import { Alert } from './alert.entity';

@Entity('projects')
export class Project {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 50, unique: true })
  projectName: string;

  @Column({ length: 100, nullable: true })
  description: string;

  @Column({ length: 50, nullable: true })
  owner: string;

  @Column({
    type: 'enum',
    enum: ['running', 'stopped', 'maintenance'],
    default: 'running',
  })
  status: string;

  @Column({ type: 'timestamp', default: () => 'CURRENT_TIMESTAMP' })
  createdAt: Date;

  @OneToMany(() => ProjectMetric, (metric) => metric.project)
  metrics: ProjectMetric[];
  
  @OneToMany(() => Alert, (alert) => alert.project)
  alerts: Alert[];
}